import WalletActiveIcon from '@/assets/icons/wallet.png'
import InviteIcon from '@/assets/icons/invite.png'
import SettingsIcon from '@/assets/icons/settings-1.png'
import ServicesIcon from '@/assets/icons/services.png'
import ExitActiveIcon from '@/assets/icons/exit.png'
import { useAppStore } from '@/stores/app'
import { Dialog } from 'vant'

/** @type {import('vue-router').RouteConfig[]} */
export const personalMenuRoutes = [
  {
    path: '/wallet',
    component: () => import('@/views/WalletView.vue'),
    meta: {
      name: '我的钱包',
      icon: WalletActiveIcon,
      isRoute: true,
      title: '钱包',
      navbarRightText: '明细',
      navbarRightPath: '/wallet-detail'
    }
  },
  {
    path: '/invite',
    component: () => import('@/views/InviteView.vue'),
    meta: {
      name: '邀请管理',
      icon: InviteIcon,
      isRoute: true,
      title: '邀请管理',
      navbarRightText: '记录',
      navbarRightPath: '/invite-record'
    }
  },
  {
    path: '/settings',
    component: () => import('@/views/SettingsView.vue'),
    meta: {
      name: '安全设置',
      icon: SettingsIcon,
      isRoute: true,
      title: '安全设置'
    }
  },
  // {
  //   path: '/publish',
  //   component: () => import('@/views/PublishedView.vue'),
  //   meta: {
  //     name: '我的发布',
  //     icon: SendActiveIcon,
  //     isRoute: true,
  //   }
  // },
  {
    meta: {
      name: '联系客服',
      icon: ServicesIcon,
      isRoute: false,
      url: process.env.VUE_APP_SERVICE_URL
     
    }
  },
  {
    meta: {
      name: '安全退出',
      icon: ExitActiveIcon,
      isRoute: false,
      async onClick() {
        const appStore = useAppStore()

        const type = await Dialog.confirm({
          title: '提示',
          message: '是否退出登录？',
        }).catch(() => { })

        if (type === 'confirm') {
          appStore.logout()
        }
      }
    }
  },
]

export const personalMenuList = personalMenuRoutes.map(route => {
  return {
    path: route.path,
    name: route.meta.name,
    icon: route.meta.icon,
    isRoute: route.meta.isRoute,
    url: route.meta.url,
    onClick: route.meta.onClick
  }
})
